<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/8/6/006
 * Time: 11:25
 */

namespace app\admin\validate;


use think\Validate;

class User extends Validate
{
    protected $rule = [
        'phone'  =>  'require|regex:/^1\d{10}$/',
        'nickname' =>  'require|max:10|min:3',
        'sex'=>'require',
        'pass' =>  'require|min:6|max:16|alphaDash|confirm:repass',

    ];

    protected $message = [
        'phone.require'  =>  '请填写手机号',
        'phone.regex'  =>  '请填写正确手机号',
        'nickname.require' =>  '请填写昵称',
        'nickname.max' =>  '昵称最多为10个字符',
        'nickname.min' =>  '昵称最少为3个字符',
        'sex.require' =>  '请选择性别',
        'pass.require' =>  '请输入密码',
        'pass.min' =>  '密码最少为6位字符',
        'pass.max' =>  '密码最大为16位字符',
        'pass.alphaDash' =>  '密码只能由字母和数字，下划线_及破折号-组成',
        'pass.confirm' =>  '两次密码输入不一致',
    ];

    protected $scene = [
        'add'   =>  ['phone','nickname','sex','pass'],
        'edit'   =>  ['phone','nickname','sex'],
    ];
}